package com.shanzhe.eshop.common.hdfs.nameNode.server;

/**
 * @Author yinwei
 * @create 2021/10/10
 * @Version 1.0
 * @desc nameNode核心启动类
 */
public class NameNode {

    /**
     * nameNode是否在运行
     */
    private volatile Boolean shouldRun;

    /**
     * 负责管理元数据的核心组件
     */
    private FsNameSystem fsNameSystem;

    /**
     * nameNode的Rpc接口
     */
    private NameNodeRpcServer nameNodeRpcServer;



    /**
     * nameNode初始化
     */
    private void initialize(){
        this.fsNameSystem = new FsNameSystem();
        this.nameNodeRpcServer = new NameNodeRpcServer(this.fsNameSystem);
        this.nameNodeRpcServer.start();
    }

    private void run(){
        try {
            while (shouldRun){
                Thread.sleep(60 * 1000);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    public NameNode(){
        this.shouldRun = true;
    }

    public static void main(String[] args) {
        NameNode nameNode = new NameNode();
        nameNode.initialize();
        nameNode.run();
    }


}
